s=input("ввелите последовательность скобок:")
s1=''
k1=s.count(')')
k2=s.count(']')
k3=s.count('}')
k4=s.count('>')
for char in s:
    if char=='(':
        s1+=char
    if char==')':
        if len(s1) > 0 and s1[len(s1)-1] == '(':
            s1 = s1[:-1]
            k1 = k1 - 1
    if char=='[':
        s1+=char
    if char==']':
        if len(s1) > 0 and s1[len(s1)-1] == '[':
            s1 = s1[:-1]
            k2 = k2 - 1
    if char=='{':
        s1+=char
    if char=='}':
        if len(s1) > 0 and s1[len(s1)-1] == '{':
            s1 = s1[:-1]
            k3 = k3 - 1
    if char=='<':
        s1+=char
    if char=='>':
        if len(s1) > 0 and s1[len(s1)-1] == '<':
            s1 = s1[:-1]
            k4 = k4 - 1
if len(s1) == 0 and k1 == 0 and k2 == 0 and k3 == 0 and k4 == 0:
    print('True')
else:
    print('False')
